package org.eae.eldf.dao.sys.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import org.eae.eldf.dao.sys.ISysPurviewDao;
import org.eae.eldf.dto.sys.SysPurviewQueryDto;
import org.eae.eldf.entity.module.ModulePurview;
import org.eae.eldf.entity.sys.SysPurview;
import org.eae.eldf.framework.dao.JdbcDaoImpl;
import org.eae.eldf.framework.pager.Pagination;

@Repository
public class SysPurviewDaoImpl extends JdbcDaoImpl implements ISysPurviewDao{
	@Override
	public Pagination<SysPurview> purList(Pagination<SysPurview> page,
			Long parentId) {
		StringBuffer sql=new StringBuffer("SELECT * FROM SYS_PURVIEW P WHERE P.PARENTID=? ");
		List<Object> param = new ArrayList<Object>();
		param.add(parentId);
		return this.queryListByPage(page, sql.toString(),param,SysPurview.class);
	}

	@Override
	public Pagination<SysPurview> queryPagePurviewList(Pagination<SysPurview> pager,
			SysPurviewQueryDto sysPurviewQueryDto) {
		// TODO Auto-generated method stub
		StringBuffer sql = new StringBuffer("select * from sys_purview t ");
		List<Object> params = new ArrayList<Object>();
		if (sysPurviewQueryDto!=null) {
		if (sysPurviewQueryDto.getParentid()!=null) {
			sql.append("where t.parentid = ?");
			params.add(sysPurviewQueryDto.getParentid());
		}
		}
		sql.append(" order by t.sys_purview_id desc");
		return this.queryListByPage(pager, sql.toString(), params,
				SysPurview.class);
		
	}

}
